﻿using Abp.MultiTenancy;
using AbpProjectTemplate.Domain.Users;
using System;

namespace AbpProjectTemplate.Components.Authorization
{
    /// <summary>
    /// 用于指定枚举为系统权限，指定的类型会自动注册到权限系统
    /// 如果是自定义验证逻辑，则不需要添加此特性
    /// </summary>
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Enum)]
    public class PermissionDefineAttribute : Attribute
    {
        public PermissionDefineAttribute(UserType userType = PermissionDefine.DefaultUserType)
            : this(null, userType, PermissionDefine.DefaultTenancySides)
        {
            //this.UserType = userType;
        }
        public PermissionDefineAttribute(string displayName,
            UserType userType = PermissionDefine.DefaultUserType,
            MultiTenancySides multiTenancySides = PermissionDefine.DefaultTenancySides)
        {
            this.DisplayName = displayName;
            this.UserType = userType;
            this.MultiTenancySides = multiTenancySides;
        }
        /// <summary>
        /// 权限的用户类型（默认为管理员权限）
        /// </summary>
        public UserType UserType { get; set; }
        /// <summary>
        /// 显示名称
        /// </summary>
        public string DisplayName { get; set; }
        /// <summary>
        /// 权限的租户类型
        /// </summary>
        public MultiTenancySides MultiTenancySides { get; set; }
    }
}

